<!DOCTYPE html>
<html lang="en-US">
  <head>
    <meta charset="utf-8" />
    {% block head %}
      <link href="{{ url_for('.static', filename='icons/search.png') }}" rel="shortcut icon">
    {% endblock %}
    <title>{% block title %}DXR Code Index{% endblock %}</title>

    {% block site_css %}
      <link href="{{ url_for('.static', filename='css/dxr.css') }}" rel="stylesheet" type="text/css" media="screen" />
      <link href="{{ url_for('.static', filename='css/forms.css') }}" rel="stylesheet" type="text/css" media="screen" />
      <link href="{{ url_for('.static', filename='css/icons.css') }}" rel="stylesheet" type="text/css" media="screen" />
      <link href="{{ url_for('.static', filename='css/code-style.css') }}" rel="stylesheet" type="text/css" media="screen" />
      <link href="{{ url_for('.static', filename='css/selector-common.css') }}" rel="stylesheet" type="text/css" media="screen" />
      <link href="{{ url_for('.static', filename='css/filter.css') }}" rel="stylesheet" type="text/css" media="screen" />
    {% endblock %}
  </head>
  <body>

    <div class="header">
        <div class="help-icon">
            <div class="help-msg">
                <p>DXR is a code search and navigation tool aimed at making sense of large projects. It supports full-text and regex searches as well as structural queries.</p>
                <ul>
                    <li><a href="https://github.com/mozilla/dxr">DXR on GitHub</a></li>
                    <li><a href="https://dxr.readthedocs.org/en/latest/">How to Get Involved</a></li>
                </ul>
            </div>
        </div>
        <form method="get" action="{{ url_for('.search', tree=tree) }}" id="basic_search" class="search-box">
            <fieldset>
                <div id="search-box" class="flex-container" role="group">
                    <div class="elem_container find">
                        <label for="query" class="query_label visually-hidden">Find</label>
                        <input type="text" name="q" {% if should_autofocus_query %}autofocus {% endif %}value="{{ query }}" maxlength="2048" id="query" class="query" accesskey="s" title="Search" placeholder="Search {{ tree }}" autocomplete="off" />
                        <div class="zero-size-container">
                        {% block bubble %}
                          <div class="bubble">
                          </div>
                        {% endblock %}
                        </div>
                        <section id="search-filter" class="search-filter">
                          <button type="button" class="sf-select-trigger" aria-label="Select Filter">
                              <!-- arrow icon using icon font -->
                              <span aria-hidden="true" data-filter-arrow="&#xe801;" class="sf-selector-arrow">
                                  Operators
                              </span>
                          </button>
                        </section>
                        <div class="sf-select-options sf-modal" aria-expanded="false">
                          <table class="selector-options" tabindex="-1">
                            {% for filter in filters %}
                              <tr data-value="{{ filter.name }}:">
                                <td class="selector-option-label">
                                  {{ filter.name }}
                                </td>
                                <td class="selector-badges">
                                  {% for text, color in filter.badges -%}
                                    {%- if color -%}
                                      <span style="background-color:{{ color }}">{{ text }}</span>
                                    {%- endif -%}
                                  {%- endfor %}
                                </td>
                                <td class="selector-option-description">
                                  {{ filter.description }}
                                </td>
                              </tr>
                            {% endfor %}
                          </table>
                        </div>
                    </div>
                </div>
            </fieldset>

            <noscript>Please turn on JavaScript to use DXR.</noscript>

            <input type="hidden" value="{{ tree }}" id="ts-value" />
            <input type="hidden" name="redirect" value="true" id="redirect" />
            <input type="submit" value="Search" class="visually-hidden" />
        </form>
    </div>

    {% block nav_bar %}
      <nav class="nav-bar">
        <div class="current-tree-nav">
          <div class="breadcrumbs">
            {%- for path, name in paths_and_names -%}
              {%- if not loop.first or loop.last and loop.length != 1 -%}
                <span class="path-separator">/</span><a href="{{ www_root }}{{ path }}">{{ name }}</a>
              {%- else -%}
                <a href="{{ www_root }}{{ path }}">{{ name }}</a>
              {%- endif -%}
            {%- endfor -%}
          </div>
        </div>
        {{ tree_menu(tree_tuples, tree) }}
      </nav>
    {% endblock %}
    
    <div id="content" class="content">
      {% block content %}
      {% endblock %}
    </div>

    {% block footer %}
      {% if generated_date %}
        <div id="foot" class="footer">
          This page was generated by DXR
          <span class="pretty-date" data-datetime="{{ generated_date }}"></span>.
        </div>
      {% endif %}
    {% endblock %}

    {% set eof = True if state_eof else False %}

    <!-- avoid inline JS and use data attributes instead. Hackey but hey... -->
    <span id="data" data-root="{{ www_root }}" data-lines="{{ url_for('.lines', tree=tree) }}" data-search="{{ url_for('.search', tree=tree) }}" data-tree="{{ tree }}"></span>
    <span id="state" data-offset="{{state_offset or 0}}" data-limit="{{state_limit or 100}}" data-results-line-count="{{ results_line_count }}" data-eof="{{ eof }}"></span>

    {% block site_js %}
      <script src="{{ url_for('.static', filename='js/libs/jquery203.js') }}"></script>
      <script src="{{ url_for('.static', filename='js/libs/nunjucks-slim.min.js') }}"></script>
      <script src="{{ url_for('.static', filename='js/templates.js') }}"></script>
      <script src="{{ url_for('.static', filename='js/utils.js') }}"></script>
      <script src="{{ url_for('.static', filename='js/dxr.js') }}"></script>
      <script src="{{ url_for('.static', filename='js/context_menu.js') }}"></script>
      <script src="{{ url_for('.static', filename='js/filter.js') }}"></script>
    {% endblock %}

    {% if google_analytics_key %}
      <script type="text/javascript">

        var _gaq = _gaq || [];
        _gaq.push(['_setAccount', '{{ google_analytics_key }}']);
        _gaq.push(['_trackPageview']);

        (function() {
          var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
          ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
          var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
        })();

      </script>
    {% endif %}

  </body>
</html>
